package com.hly.musicbackground.model.admin.rest;

import com.hly.musicbackground.model.admin.params.VersionParams;
import com.hly.musicbackground.model.auth.service.VersionService;
import com.hly.musicbackground.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 管理端版本
 * */
@RestController
@RequestMapping("/api/admin/version")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(tags = "管理端版本")
public class AdminVersionController {

    private final VersionService versionService;

    @PostMapping("/edit")
    @ApiOperation(value = "添加/修改版本")
    public Result edit(@RequestBody VersionParams params){
        versionService.editVersion(params);
        return Result.ok();
    }

    @PostMapping("/del")
    @ApiOperation(value = "批量删除版本")
    public Result del(@RequestParam("ids") String ids){
        versionService.removeBatchByIds(Arrays.asList(ids.split(",")));
        return Result.ok();
    }

}
